<template>
  <div class="nav-header">
    <i
      class="fold-menu"
      :class="isFold ? 'el-icon-s-fold' : 'el-icon-s-unfold'"
      @click="handleFoldClick"
    ></i>
    <div class="content">
      <my-bread-crumb :breadcrumbs="breadcrumbs" />
      <user-info />
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from '@vue/reactivity'
import MyBreadCrumb, { IBreadcrumb } from '@/base-ui/breadcrumb'
import userInfo from './userInfo.vue'
import { pathMapBreadCrumbs } from '@/utils/map-menus'
import { useStore } from '@/store'
import { useRoute } from 'vue-router'
import { computed } from '@vue/runtime-core'

const store = useStore()
const userMenu = store.state.login.userMenu

const breadcrumbs = computed(() => {
  const route = useRoute()
  const currentPath = route.path
  return pathMapBreadCrumbs(userMenu, currentPath)
})

const emit = defineEmits(['foldChange'])
const isFold = ref(false)
const handleFoldClick = () => {
  isFold.value = !isFold.value
  emit('foldChange', isFold.value)
}
</script>

<style scoped lang="less">
.nav-header {
  display: flex;
  width: 100%;

  .fold-menu {
    font-size: 30px;
    cursor: pointer;
  }

  .content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    padding: 0 20px;
  }
}
</style>
